package com.emser.unc.client.view;

import com.emser.unc.serializable.SellerDTO;
import com.google.gwt.cell.client.AbstractCell;
import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.user.client.ui.AbstractImagePrototype;

public class CellCustom extends AbstractCell<SellerDTO>{
	 private final String imageHtml;

	 public CellCustom(ImageResource image) {
	      this.imageHtml = AbstractImagePrototype.create(image).getHTML();
	}

	@Override
	public void render(com.google.gwt.cell.client.Cell.Context context, SellerDTO value, SafeHtmlBuilder sb) {
	      if (value == null) {
	        return;
	      }
	      sb.appendHtmlConstant("<table>");
	      sb.appendHtmlConstant("<tr><td rowspan='3'>");
	      sb.appendHtmlConstant(imageHtml);
	      sb.appendHtmlConstant("</td>");
	      sb.appendHtmlConstant("<td style='font-size:95%;'>");
	      sb.appendEscaped(value.getFirstName()+" "+value.getLastName());
	      sb.appendHtmlConstant("</td></tr><tr><td>");
		  sb.appendEscaped(value.getTelephone());
	      sb.appendHtmlConstant("</td></tr></table>");
	}

}
